﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace assignment6
{
    public partial class AddOrderForm : Form
    {
        public AddOrderForm(OrderService os)
        {
            orderService = os;
            InitializeComponent();
        }

        private void 明细_Click(object sender, EventArgs e)
        {

        }

        private void addDetail_btn_Click(object sender, EventArgs e)
        {
            details.Add(new OrderDetail(name_text.Text, int.Parse(quantity_text.Text), double.Parse(singleprice_text.Text)));
            name_text.Text = "";
            quantity_text.Text = "";
            singleprice_text.Text = "";
            detail_show.Text+=details[details.Count-1].ToString()+"\n";
        }

        private void submit_btn_Click(object sender, EventArgs e)
        {
            Order order = new Order(details, int.Parse(id_text.Text), customname_text.Text);
            orderService.AddOrder(order);
            this.Text = "添加成功";
        }

        private void AddOrderForm_Load(object sender, EventArgs e)
        {

        }
    }
}
